package main

import (
	"fmt"
)

type Pay interface {
	PayPage(price int64) string
}
type AliPay struct{}

func (a AliPay) PayPage(price int64) string {
	return "支付宝支付"
}

type WxPay struct{}

func (w WxPay) PayPage(price int64) string {
	return "微信支付"
}

type YlPay struct{}

func (y YlPay) PayPage(price int64) string {
	return "银联支付"
}

// Refund 退款产品
type Refund interface {
	Refund(no string) error
}
type AliRefund struct {
}

func (r AliRefund) Refund(no string) error {
	fmt.Println("支付宝退款")
	return nil
}

type WxRefund struct {
}

func (r WxRefund) Refund(no string) error {
	fmt.Println("微信退款")
	return nil
}

type PayFactory interface {
	CreatePay() Pay
	CreateRefund() Refund
}

// 创建2个工厂
type AliPayFactory struct {
}

func (a AliPayFactory) CreatePay() Pay {
	return AliPay{}
}
func (a AliPayFactory) CreateRefund() Refund {
	return AliRefund{}
}

type WxPayFactory struct {
}

func (w WxPayFactory) CreatePay() Pay {
	return WxPay{}
}
func (w WxPayFactory) CreateRefund() Refund {
	return WxRefund{}
}

func main() {
	ali := AliPayFactory{}
	pay := ali.CreatePay()
	fmt.Println(pay.PayPage(32))
	err := ali.CreateRefund().Refund("23")
	if err != nil {
		return
	}

}
